<?php
    class User extends CActiveRecord
    {
        public static function model($className = __CLASS__) {
            return parent::model ( $className );
        }

        public function tableName() {                  
            return 'c_user';
        }
        public function getUserId($username)
        {
            $sql = "SELECT id FROM c_user WHERE username='" . mysql_escape_string($username) . "'";
            $command = Yii::app()->db->createCommand($sql);
            $row = $command->queryRow();
            return $row['id'];
        }
        public function getUserIdByDomain($domain)
        {
            $sql = "SELECT user_id, user_name FROM c_shop_domain WHERE domain='" . mysql_escape_string($domain) . "'";
            $command = Yii::app()->db->createCommand($sql);
            $rows = $command->queryRow();
            return $rows;
        }
    }  
?>